#!/usr/bin/env python
from astropy.table import Table
import sys
import numpy as np

tab = Table.read(sys.argv[1],format='ipac')
wave = tab['wave']
idx = np.argsort(wave)
tab = tab[idx]
tab.write(sys.argv[1].replace(".cat","_sort.cat"),format='ipac',overwrite=True)
